package com.enjoyor.soa.traffic.server.efoms.dubbo.invoke;

import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.service.dubbo.collectms.IDubboCollectmsCallbackListener;
import com.enjoyor.soa.traffic.api.service.dubbo.collectms.IDubboDevStatusCallbackService;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

@Component
public class DubboCollectCallbackServiceInvoke {

	@Reference(timeout = 10000)
    private IDubboDevStatusCallbackService dubboDevStatusCallbackService ;

	/**
	 * 向回调服务中注册一个监听器
	 * @param listener 监听器
	 */
	public void addCollectDevListener(String listenerId, IDubboCollectmsCallbackListener devStatusListener){
		if (null != dubboDevStatusCallbackService) {
			dubboDevStatusCallbackService.addDevStatusListener(devStatusListener);
        }
    }
	
    /**
     * 获取采集设备状态信息
     * @return
     */
    public ResultPojo getCollectStatusInfo() {
        ResultPojo pojo = new ResultPojo();
    	if (null != dubboDevStatusCallbackService) {
    		pojo = dubboDevStatusCallbackService.getDevStatus();
    	}
        return pojo;
    }
    
    /**
     * 根据设备编号获取采集设备状态信息
     * @return
     */
    public ResultPojo getCollectStatusInfoById(String devId) {
        ResultPojo pojo = new ResultPojo();
    	if (null != dubboDevStatusCallbackService) {
    		pojo = dubboDevStatusCallbackService.getDevStatusByDevId(devId);
    	}
        return pojo;
    }
}
